package com.amigo.online.provider.user.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import com.amigo.online.common.core.mybatis.MyMapper;
import com.amigo.online.provider.user.model.entity.UserLike;


@Mapper
@Component
public interface UserLikeMapper extends MyMapper<UserLike> {

    @Select("select count(*) from user_tan_like_tbl where user_id = #{id} and created_time between #{lastDayTime} and #{nowTime}")
    int daySelectCount(@Param("id") Long id, @Param("lastDayTime") Long lastDayTime, @Param("nowTime") Long nowTime);

    @Update("update user_tan_like_tbl set remark = 1 where (user_id = #{id} and user_like_id = #{userId}) or (user_like_id = #{id} and user_id = #{userId})")
    int updateRelation(@Param("userId") Long userId, @Param("id") Long id);

    @Select("select a.user_like_id from user_tan_like_tbl a where a.remark = 1 and user_id = #{userId}")
    List<Long> selectProbePersonId(@Param("userId") Long userId);

    @Select("select count(*) from user_tan_like_tbl where user_id = #{userId} and user_like_id = #{userLikeId}")
    int countIsLike(@Param("userId") Long userId, @Param("userLikeId") Long userLikeId);

    @Select("SELECT user_id FROM user_tan_like_tbl where user_like_id = #{id}")
    List<Long> selectLikeMe(@Param("id")Long id);
}
